package com.weiqk.pmdemo.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.weiqk.pmdemo.controller.R.R;
import com.weiqk.pmdemo.dto.ApplyLinkInDto;
import com.weiqk.pmdemo.dto.PayLinkInDto;
import com.weiqk.pmdemo.service.PayLinkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags="支付环节接口")
@Slf4j
@RestController
@RequestMapping("/PayLink")
public class PayLinkController {
    @Autowired
    PayLinkService payLinkService;

    @ApiOperation("获取全部")
    @ApiOperationSupport(author = "EDSION")
    @GetMapping("/getAll")
    @ResponseBody
    public R GetAll(){
        R r = new R();
        r.setData(payLinkService.findAll());
        r.setS(true);
        return r;
    }
    @ApiOperation("根据id删除")
    @ApiOperationSupport(author = "EDSION")
    @DeleteMapping("/{id}")
    @ResponseBody
    public R DeleteById(@PathVariable Integer id){
        R r = new R();
        r.setS(payLinkService.deleteById(id));
        return r;
    }
    @ApiOperation("更新")
    @ApiOperationSupport(author = "EDSION")
    @PostMapping("update")
    @ResponseBody
    public R Update(@RequestBody PayLinkInDto payLinkInDto){
        R r = new R();
        r.setS(payLinkService.update(payLinkInDto));
        return r;
    }
    @ApiOperation("新增")
    @ApiOperationSupport(author = "EDSION")
    @PostMapping("put")
    @ResponseBody
    public R Put(@RequestBody PayLinkInDto payLinkInDto){
        R r = new R();
        r.setS(payLinkService.put(payLinkInDto));
        return r;
    }
}
